//
//  MIneTableViewCell.m
//  0.3camera
//
//  Created by 茶 on 2023/11/24.
//

#import "MIneTableViewCell.h"

@interface MIneTableViewCell ()

@property (nonatomic, strong) UIView *backView;
@property (nonatomic, strong) UILabel *titleLabel;
@property (nonatomic, strong) UILabel *vipLabel;

@property (nonatomic, strong) UIImageView *arrowImgView;

@end

@implementation MIneTableViewCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self initInterface];
    }return self;
}

- (void)initInterface {
    self.selectionStyle = UITableViewCellSelectionStyleNone;
    self.backgroundColor = self.contentView.backgroundColor = HexColor(@"#F8F8F8");
    
    _backView = [UIView new];
    _backView.layer.cornerRadius = CARatioWidth(10);
    [self.contentView addSubview:_backView];
    [_backView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.ca_offset(15);
        make.right.ca_offset(-15);
        make.top.ca_offset(7.5);
        make.bottom.ca_offset(-7.5);
    }];
    
    _titleLabel = [UILabel new];
    _titleLabel.textColor = HexColor(@"#29282A");
    _titleLabel.font = CAFontScaleRegular(16);
    [self.contentView addSubview:_titleLabel];
    [_titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.mas_equalTo(0);
        make.left.ca_offset(30);
    }];
    
    _vipLabel = [UILabel new];
    _vipLabel.textColor = HexColor(@"#29282A");
    _vipLabel.backgroundColor = UIColor.whiteColor;
    _vipLabel.textAlignment = NSTextAlignmentCenter;
    _vipLabel.layer.cornerRadius = CARatioWidth(10);
    _vipLabel.layer.masksToBounds = YES;
    _vipLabel.text = @"开通";
    _vipLabel.font = CAFontScaleRegular(12);
    [self.contentView addSubview:_vipLabel];
    [_vipLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.ca_offset(-30);
        make.centerY.mas_equalTo(0);
        make.height.ca_offset(20);
        make.width.ca_offset(60);
    }];
    
    _arrowImgView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"Mine_Arrow"]];
    [self.contentView addSubview:_arrowImgView];
    [_arrowImgView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.ca_offset(-30);
        make.centerY.mas_equalTo(0);
    }];
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}


- (void)setType:(NSUInteger)type {
    if (type == 0) {
        _backView.backgroundColor = HexColor(@"#29282A");
        _titleLabel.textColor = UIColor.whiteColor;
        _arrowImgView.hidden = YES;
        _vipLabel.hidden = kUserModel.vipStatus;
        
    } else {
        _arrowImgView.hidden = NO;
        _backView.backgroundColor = UIColor.whiteColor;
        _vipLabel.hidden = YES;
        _titleLabel.textColor = HexColor(@"#29282A");

    }
}

- (void)setTitle:(NSString *)title {
    if ([title isEqualToString:@"会员享用所有功能"]) {
        if (kUserModel.vipStatus) {
            
            _titleLabel.text = [NSString stringWithFormat:@"会员到期时间：%@", kUserModel.vipEndStr];

        } else {
            _titleLabel.text = title;
            
        }
    } else {
        _titleLabel.text = title;
    }
}

@end
